import { configureStore } from '@reduxjs/toolkit';
import user from './reducer/user';
import role from './reducer/role';
import path from './reducer/path';
import menu from './reducer/menu';
import report from './reducer/report';
import reportDetail from './reducer/reportDetail';


export const store = configureStore({
    reducer: {
        /** 用户状态管理 */
        user,
        /** 角色状态管理 */
        role,
        /** 请求路径状态管理 */
        path,
        /** 菜单状态管理 */
        menu,
        /** 报销单状态管理 */
        report,
        /** 报销记录状态管理 */
        reportDetail,
    },
    // middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger).concat(thunk)
});

const state = store.getState();
/**
 * store的keys的key的联合类型
 */
export type StoreKeys = keyof typeof state;

// Infer the `RootState` and `AppDispatch` types form the store itself
export type RootState = ReturnType<typeof store.getState>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;
export default store;